<template>
  <div class="questionnaire-list-container">
    <!-- 头部 -->
    <div class="header-bar">
      <van-icon name="arrow-left" class="back-icon" @click="goBack" />
      <h2 class="header-title">问卷列表</h2>
      <div class="header-actions">
        <van-icon name="more-o" size="20" />
        <van-icon name="aim" size="20" style="margin-left: 10px;" />
      </div>
    </div>

    <!-- 问卷列表 -->
    <div class="questionnaire-list">
      <div 
        v-for="questionnaire in questionnaires" 
        :key="questionnaire.id"
        class="questionnaire-card"
        @click="goToDetail(questionnaire.id)"
      >
        <div class="card-content">
          <div class="card-left">
            <h3 class="card-title">{{ questionnaire.title }}</h3>
            <p class="card-participants">{{ questionnaire.participantCount }}人已参与</p>
          </div>
          <div class="card-right">
            <div class="card-icon">
              <div class="icon-shape icon-shape-1"></div>
              <div class="icon-shape icon-shape-2"></div>
            </div>
            <van-button type="primary" size="small" class="participate-btn">立即参与</van-button>
          </div>
        </div>
        <div class="card-pattern"></div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { questionnaires } from './data'

const router = useRouter()

const goBack = () => {
  router.back()
}

const goToDetail = (id: number) => {
  router.push(`/questionnaire/${id}`)
}
</script>

<style scoped>
.questionnaire-list-container {
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 20px;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-icon {
  font-size: 20px;
  cursor: pointer;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  text-align: center;
}

.header-actions {
  display: flex;
  align-items: center;
}

.questionnaire-list {
  padding: 15px;
}

.questionnaire-card {
  background-color: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.questionnaire-card:active {
  transform: scale(0.98);
}

.card-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  z-index: 2;
}

.card-left {
  flex: 1;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 8px 0;
}

.card-participants {
  font-size: 12px;
  color: #999;
  margin: 0;
}

.card-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.card-icon {
  position: relative;
  width: 40px;
  height: 50px;
}

.icon-shape {
  position: absolute;
  width: 30px;
  height: 40px;
  border-radius: 6px;
  background: linear-gradient(135deg, #4FC3F7 0%, #81D4FA 100%);
  opacity: 0.8;
}

.icon-shape-1 {
  left: 0;
  top: 0;
  transform: rotate(-5deg);
}

.icon-shape-2 {
  right: 0;
  top: 10px;
  transform: rotate(5deg);
  opacity: 0.6;
}

.participate-btn {
  white-space: nowrap;
  border-radius: 20px;
  padding: 0 20px;
}

.card-pattern {
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 120px;
  height: 120px;
  background-image: 
    repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(79, 195, 247, 0.05) 10px, rgba(79, 195, 247, 0.05) 20px),
    repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(79, 195, 247, 0.05) 10px, rgba(79, 195, 247, 0.05) 20px);
  opacity: 0.3;
  z-index: 1;
}
</style>

